// pages/villageOrder/villageOrder.js
// var util = require('../../utils/util.js')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    orderNumber:10,
    orderIncome:500,
    orderMoney:500,
    orderNoMoney:0,
    orderType: 0,// 内容初始化
    headMode: 'aspectFit', //保持纵横比缩放图片，使图片的长边能完全显示出来。也就是说，可以完整地将图片显示出来。
    // 全部
    allLists:[
      {
        orderNo:'1234322122',
        orderStatu:'已付款待提货',
        proImg:'../../images/peo_1.png',
        proName:'商品名称商品名称',
        proUser:'12343234434',
        proTime:'2019-01-17  12:00:00',
        proMoney:80,
        proPrent:10,
        proReAmount:''
        // proReMoney: 
      },
      {
        orderNo: '1234322122',
        orderStatu: '已核销已返佣',
        proImg: '../../images/peo_1.png',
        proName: '商品名称商品名称',
        proUser: '12343234434',
        proTime: '2019-01-17  12:00:00',
        proMoney: 80,
        proPrent: 5,
        proReAmount: 4
        // proReMoney: 
      },
      {
        orderNo: '1234322122',
        orderStatu: '交易取消，全额退款',
        proImg: '../../images/peo_1.png',
        proName: '商品名称商品名称',
        proUser: '12343234434',
        proTime: '2019-01-17  12:00:00',
        proMoney: 80,
        proPrent: 10,
        proReAmount: '',
        // proReMoney: 
      },
      {
        orderNo: '1234322122',
        orderStatu: '交易取消，部分退款',
        proImg: '../../images/peo_1.png',
        proName: '商品名称商品名称',
        proUser: '12343234434',
        proTime: '2019-01-17  12:00:00',
        proMoney: 80,
        proPrent: 10,
        proReAmount: '',
        proReMoney: 20
      },
      {
        orderNo: '1234322122',
        orderStatu: '交易取消，补偿退款',
        proImg: '../../images/peo_1.png',
        proName: '商品名称商品名称',
        proUser: '12343234434',
        proTime: '2019-01-17  12:00:00',
        proMoney: 80,
        proPrent: 10,
        proReAmount: '',
        proReMoney: 20
      }
    ],
    // 待提货
    waitLists: [
      {
        orderNo: '1234322122',
        orderStatu: '已付款待提货',
        proImg: '../../images/peo_1.png',
        proName: '商品名称商品名称',
        proUser: '12343234434',
        proTime: '2019-01-17  12:00:00',
        proMoney: 80,
        proPrent: 10,
        proReAmount: ''
        // proReMoney: 
      }
    ],
    // 已返佣
    hasLists: [
      {
        orderNo: '1234322122',
        orderStatu: '已核销已返佣',
        proImg: '../../images/peo_1.png',
        proName: '商品名称商品名称',
        proUser: '12343234434',
        proTime: '2019-01-17  12:00:00',
        proMoney: 80,
        proPrent: 10,
        proReAmount: 4
        // proReMoney: 
      },
    ],
    // 交易取消
    cancelLists: [
      {
        orderNo: '1234322122',
        orderStatu: '交易取消，全额退款',
        proImg: '../../images/peo_1.png',
        proName: '商品名称商品名称',
        proUser: '12343234434',
        proTime: '2019-01-17  12:00:00',
        proMoney: 80,
        proPrent: 10,
        proReAmount: ''
        // proReMoney: 
      },
      {
        orderNo: '1234322122',
        orderStatu: '交易取消，部分退款',
        proImg: '../../images/peo_1.png',
        proName: '商品名称商品名称',
        proUser: '12343234434',
        proTime: '2019-01-17  12:00:00',
        proMoney: 80,
        proPrent: 10,
        proReAmount: '',
        proReMoney: 20
      },
      {
        orderNo: '1234322122',
        orderStatu: '交易取消，补偿退款',
        proImg: '../../images/peo_1.png',
        proName: '商品名称商品名称',
        proUser: '12343234434',
        proTime: '2019-01-17  12:00:00',
        proMoney: 80,
        proPrent: 10,
        proReAmount: '',
        proReMoney: 20
      }
    ],
    showModal: false, //查询Dialog初始化
    //picker初始化
    startDate: '',
    endDate: '',
  },

  // 订单内容切换
  changeNav: function (e) {
    var that = this;
    var number = e.target.dataset.num
    that.setData({
      orderType: number
    })
  },

  // 查询Dialog
  showDialogBtn: function (e) {
    this.setData({
      showModal: true
    })
  },

  //点击遮幕层Dialog消失
  bindMask: function (e) {
    this.setData({
      showModal: false
    })
  },

  // 开始时间
  bindStartDate: function (e) {
    // debugger
    console.log(e.detail.value)
    var that = this
    var value = e.detail.value//e开始时间
    var startDate = that.data.startDate //开始时间
    var endDate = that.data.endDate //结束时间
    var endDateNew = ''//结束
    if (endDate != '' && endDate < value){
      wx.showToast({
        title: '结束时间不能小于开始时间',
        icon: 'none',
        duration: 3000
      })
      endDateNew = ''
    }
    that.setData({
      startDate: value,
      endDate: endDateNew,
    })
  },

  // 结束时间
  bindEndDate: function (e) {
    // debugger
    console.log(e.detail.value)
    var that = this
    var value = e.detail.value//e结束时间
    var startDate = that.data.startDate //开始时间
    var endDate = that.data.endDate //结束时间
    var endDateNew = ''//结束
    if (startDate == ''){
      wx.showToast({
        title: '请先选择开始时间',
        icon: 'none',
        duration: 2000
      })
      endDateNew = ''
    } else if (value < startDate) {
      wx.showToast({
        title: '结束时间不能小于开始时间',
        icon: 'none',
        duration: 2000
      })
      endDateNew = ''
    }else{
      endDateNew = value
    }
    that.setData({
      endDate: endDateNew,
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})